<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script type="text/javascript">
    var longestCommonPrefix = function(strs) {
        var ary=new Map();
        var i=0,j=0;
        var ans=0;
        while(i<=j&&j<strs.length)
        {
            console.log(strs[i],strs[j])
            if(ary[strs[j]]==undefined)
            {
                ary[strs[j]]=1;
                ans=Math.max(ans,j-i+1);
                j++;
            }else{
                ary[strs[i]]=undefined;
                i++;
            }
        }
        return ans;
    }
    console.log(longestCommonPrefix("pwwkew"));
    // var arr=new Map();
    // arr['1']=11;
    // arr['2']=22;
    // var arr=[1,2,3];
    // for(var key in arr)
    // {
    //     console.log(key+1);
    // }
    </script>
</body>
</html>